package com.dhcc.core.framework.beetl.func;

import java.util.Locale;

import com.dhcc.core.framework.util.HttpContextUtil;
import com.dhcc.core.framework.util.SpringContextHolder;

import org.beetl.core.Context;
import org.beetl.core.Function;
import org.springframework.web.servlet.LocaleResolver;

/**
 * 国际化获取Locale的方法
 * 
 * @ClassName: LanguageFunction
 * @Description: 描述
 * @author: cyf
 * @date: 2018年1月2日 上午9:09:53
 */
public class LanguageFunction implements Function {
	@Override
    public Object call(Object[] paras, Context ctx) {
		LocaleResolver localeResolver = SpringContextHolder.getBean("localeResolver");
		Locale local = localeResolver.resolveLocale(HttpContextUtil.getRequest());
		return local.getLanguage() + "_" + local.getCountry();
	}
}